<?php
require 'spl.php';

function string_valid($str_1, $str_2) {
    //初始化

    $Parameters = new \liyuze\Parameters\Parameters();
    //配置参数和验证规则
    $Parameters->config([
        'str_1' => [$str_1, ['string'] ],
        'str_2' => [$str_2, ['string', 'minLength' => 5, 'maxLength' => 5]],
    ]);

    //验证
    $Parameters->validate();

    return $Parameters->getErrors();
}

function test_pass()
{
    $str_1 = 'a string';
    $str_2 = '55555';
    $r = string_valid($str_1, $str_2);
    return json_encode($r, 256);
}

function test_string()
{
    $str_1 = 55555;
    $str_2 = '55555';
    $r = string_valid($str_1, $str_2);
    return json_encode($r, 256);
}

function test_min_length()
{
    $str_1 = 'a string';
    $str_2 = '4444';
    $r = string_valid($str_1, $str_2);
    return json_encode($r, 256);
}


function test_max_length()
{
    $str_1 = 'a string';
    $str_2 = '666666';
    $r = string_valid($str_1, $str_2);
    return json_encode($r, 256);
}

var_dump(
    test_pass(),
    test_string(),
    test_min_length(),
    test_max_length()
);

